import pinia from "@/store";
import useUserStore from "@/store/modules/user";
let userStore = useUserStore(pinia);

export const isHasButton = (app: any) => {
    // 全局自定义指令:实现按钮的权限
    app.directive('has', {
        mounted(el: any, options: any) {
            console.log(el, options)
            // 自定义指令右侧的数值:如果在用户信息的buttons中没有
            // 在DOM树中去除
            if (!userStore.buttons.includes(options.value)) {
                el.parentNode.removeChild(el)
            }
        },
    })
}